<template>
	<view>
		<click-input :value="_value" :disabled="readonly" index="name" @click="showOrgPicker" :placeholder="$t('module.selectDept')"
			pre-icon="home"></click-input>
		<org-picker ref="orgPicker" :multiple="props.formProps.multiple" :selected="_value" type="dept"
			@ok="selectOk"></org-picker>
	</view>
</template>

<script setup>
	import { ref, computed } from 'vue'
	import OrgPicker from '@/components/OrgPicker.vue'
	import ClickInput from '@/components/ClickInput.vue'

	const props = defineProps({
		formProps: {
			type: Object,
			default: () => {
				return {}
			}
		},
		modelValue: Object,
		readonly: Boolean
	})

	const _value = computed({
		get() {
			return props.modelValue
		},
		set(val) {
			emits('update:modelValue', val)
		}
	})

	const emits = defineEmits(['update:modelValue'])

	const orgPicker = ref()

	function showOrgPicker() {
		console.log('点击了')
		if (!props.readonly) {
			orgPicker.value.show()
		}
	}

	function selectOk(val) {
		_value.value = val
	}
</script>

<style>
</style>